/**
 * 文件名：RpcLogAspect.java
 *
 * 创建人：虞云波 - yuyunbo@3856.cc
 *
 * 创建时间：2017年10月6日 下午5:27:55
 *
 * 版权所有：晟邦物流网络科技有限公司
 */
package com.cbwl.eoas.cms.web.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cbwl.eoas.cms.api.sysconfig.ISysLogService;

/**
 * <p>[描述信息：说明类的基本功能]</p>
 *
 * @author 虞云波 - yuyunbo@3856.cc
 * @version 1.0 Created on 2017年10月6日 下午5:27:55
 */
@Aspect
@Component
public class RequestLogAspect {

	@Autowired
	private ISysLogService isysLogService;
	
	private static Logger _log = LoggerFactory.getLogger(RequestLogAspect.class);

	

//	@Before("execution(* *..controller..*.*(..))")
//	public void doBeforeInServiceLayer(JoinPoint joinPoint) {
//		_log.debug("doBeforeInServiceLayer");
//		
//	}
//
//	@After("execution(* *..controller..*.*(..))")
//	public void doAfterInServiceLayer(JoinPoint joinPoint) {
//		_log.debug("doAfterInServiceLayer");
//	}

//	@Around("execution(* com.cbwl.eoas.cms.web.controller..*.*(..))")
	public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
		
		
//			// 开始时间
//			long startTime = System.currentTimeMillis();
//			// 结束时间
//			long endTime = 0L;
//		
//			Object[] paramArray = pjp.getArgs();
//			HttpServletRequest request = (HttpServletRequest)paramArray[0];
//			SysLogDTO bean = RequestLogUtil.getRequestSysLog(request);
//			
//			try {
//				Object result = pjp.proceed();
//				
//				return result;
//			} catch (Exception ex) {
//				bean.setSysResResult(DicDetailConstant.sysresresult_2);
//				bean.setSysExceptionInfo(ExceptionUtils.getTrace(ex).length()>512?ExceptionUtils.getTrace(ex).substring(0, 512):ExceptionUtils.getTrace(ex));
//			}
//			
//			endTime = System.currentTimeMillis();
//			long runtime = (endTime-startTime)/1000;
//			
//			bean.setSysResTime(runtime);
//			bean.setGmtCreate(new Date());
//			bean.setCreater(SessionManager.getCurrentUser()==null?null:SessionManager.getCurrentUser().getId());
//			
//			bean.setSysResResult(DicDetailConstant.sysresresult_1);
//			isysLogService.saveObject(bean);
//			
			
			Object result = pjp.proceed();
			return result;
			
	}
}
